/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controle;

import classes.BancoDeDados;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * @author cardodav
 */
public class EnderecoDAO {
    
    public static int getCodigoProximo(){
    
        int ret = 0;
        
        BancoDeDados bd = new BancoDeDados();
        String query = "select (max(codigoendereco) + 1) proximoCodigo from endereco";
        ResultSet rs = bd.consultar(query);
        try{
            if (rs.next()){
                ret = rs.getInt("proximoCodigo");
            }
        } catch (SQLException ex){
            System.out.println("Erro ao retornar o proximo codigo do endereco" + ex.getMessage());        
        }
        
        return ret;            
    }  
    
}
